package com.xp.code.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Component;

/**
 * 
 * @author HAHA
 *
 */
@Component("SpringContextUtils")
public class SpringContextUtils implements BeanFactoryAware {

	private static BeanFactory globalSpringContext=null;
	
	public static BeanFactory getSpringContext() throws Exception{
		if(globalSpringContext==null){
			throw new Exception("Spring配置文件中无法获知“SpringContextUtils”！");
		}
		return globalSpringContext;
	}
	
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		this.globalSpringContext=beanFactory;
	}

}
